package client;

import java.util.GregorianCalendar;
import java.util.List;

import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import webservice.HelloService;
import webservice.MyService;
import webservice.SimpleBean;

public class HelloWsTest {

	public static void main(String[] args) {
		//通过MyService类获取HelloService实例
		HelloService helloService = new MyService().getHelloServicePort();
		
		System.out.println(helloService.aliasMethod("test"));	//方法别名调用
		System.out.println(helloService.simpleMethod("simpleName"));	//方法名调用
		
		List<SimpleBean> list = helloService.getSimpleBeanList();	//自定义类型列表获取
		for(SimpleBean sb : list) {
			System.out.println(sb);
			helloService.printSimpleBean(sb);	//此处在Service端打印
			System.out.println(helloService.simpleBean2String(sb));	//返回字符串到客户端打印
			System.out.println(sb.getName() + "  | age=" + sb.getAge());
		}
		
		SimpleBean bean = new SimpleBean();
		bean.setName("inputBean");
		bean.setAge(11);
		try {
			bean.setDate(DatatypeFactory.newInstance().newXMLGregorianCalendar(new GregorianCalendar()));
		} catch (DatatypeConfigurationException e) {
			e.printStackTrace();
		}
		helloService.printSimpleBean(bean);	//传递对象给Service端，后续进行其他操作
	}

}
